package xuhaijia.lanou3g.autohome.forum.normalforum;
//                .-~~~~~~~~~-._       _.-~~~~~~~~~-.
//            __.'              ~.   .~              `.__
//          .'//                  \./                   \\`.
//        .'//            为什么坚持  想一想当初             \\`.
//      .'// .-~"""""""~~~~-._     |     _,-~~~~"""""""~-.  \\`.
//    .'//.-"                 `-.  |  .-'                 "-. \\`.
//  .'//______.============-..   \ | /   ..-============._______\\`.
//.'//____________________________\|/_____________________________\\`.
// 
//                             

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import xuhaijia.lanou3g.autohome.R;

/**
 * Created by 7 on 16/8/21.
 */
public class ThemeAdapter extends BaseAdapter{
    Context context;
    ThemeBean themeBean;

    public ThemeAdapter(Context context) {
        this.context = context;
    }

    public void setThemeBean(ThemeBean themeBean) {
        this.themeBean = themeBean;
    }

    @Override
    public int getCount() {
        if (themeBean.getResult().getList() == null) {
            return 0;
        }
        return themeBean.getResult().getList().size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder = null;
        if (convertView == null) {
            convertView = LayoutInflater.from(context).inflate(R.layout.item_theme , null);
            viewHolder = new ViewHolder(convertView);
            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }
        viewHolder.nameTv.setText(themeBean.getResult().getList().get(position).getBbsname());
        return convertView;
    }


    private class ViewHolder {
        TextView nameTv;

        public ViewHolder(View view) {
            nameTv = (TextView) view.findViewById(R.id.item_theme_name);
        }
    }
}
